<?php
ob_start();
session_start();
$sess_id=$_SESSION['sess_id'];
$sess_user=$_SESSION['sess_user'];
$sess_status=$_SESSION['sess_status'];
$flag = $_SESSION['sess_flag'];
if ($sess_id<>session_id() || $sess_user=="" || $sess_status<>"active") {
		header( "Location: login.php");exit();
	}
///////////////////////////////////////////////////////////////////////////
include('config.inc.php');
include('runid.php');
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$charset\">";

?>
<link rel="stylesheet" type="text/css" href="epoch_styles.css" />
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript" src="js/epoch_classes.js"></script>
<?php /*<script language="JavaScript">
	var datestart,datestop;
function getform(form){

	if(form == 1){
		document.getElementById("formsearch").innerHTML = "<small><div><strong>วันที่แจ้ง : </strong> &nbsp;<input id='datefault' type='text' name='datefault'> <a href=\"javascript:getresult(document.fsearch.datefault.value,1);\" style='text-decoration:none;'>ค้นหา</a></div></small>";
		new Epoch('datefault','popup',document.getElementById('datefault'));
		document.getElementById("searchresult").innerHTML = "";
	}else if(form == 2){
		document.getElementById("formsearch").innerHTML = "<small><strong>กรุณาใส่ข้อมูล :</strong><input name='wordsearch' type='text' id='wordsearch' value='พิมพ์ชื่อผู้แจ้งที่นี่' onClick=\"this.value=''\"><a href=\"javascript:getresult(document.fsearch.wordsearch.value,2);\" style='padding:0px 0px 0px 10px;text-decoration:none;'>ค้นหา</a></small>";
		document.getElementById("searchresult").innerHTML = "";
	}else if(form == 4){
		document.getElementById("formsearch").innerHTML = "<small><div><strong>วันเริ่มต้น:</strong> &nbsp;<input id='datestart' type='text' name='datestart'> <strong>วันสุดท้าย </strong>: &nbsp;<input id='datestop' type='text' name='datestop'> <a href=\"javascript:getresult(document.fsearch.datestart.value+'-'+document.fsearch.datestop.value,4);\" style='text-decoration:none;'>ค้นหา</a></div></small>";
		getcalendar();
		document.getElementById("searchresult").innerHTML = "";
	}else if(form == 3){
		document.getElementById("formsearch").innerHTML = "<small><strong>กรุณาใส่ข้อมูล :</strong><input name='wordsearch' type='text' id='wordsearch' value='ข้อความในการแจ้ง' onClick=\"this.value=''\"><a href=\"javascript:getresult(document.fsearch.wordsearch.value,3);\" style='padding:0px 0px 0px 10px;text-decoration:none;'>ค้นหา</a></small>";
		document.getElementById("searchresult").innerHTML = "";
	}
}
function getcalendar() {  
	//bas_cal = new Epoch('epoch_basic','flat',document.getElementById('basic_container'));
	datestart  = new Epoch('datestart','popup',document.getElementById('datestart'));
	datestop = new Epoch('datestop','popup',document.getElementById('datestop'));
	//ms_cal  = new Epoch('epoch_multi','flat',document.getElementById('multi_container'),true);
}
function getresult(wordSearch,typeSearch){
	//alert(wordSearch);
	//alert(typeSearch);
	var loading = "<div id='loading'>Loading...</div>";
	var xmlHttp = GetXmlHttpObject();
	var url = 'searchdata.php';
	var pmeters = "wordsearch="+wordSearch+"&typesearch="+typeSearch;
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 0){document.getElementById("searchresult").innerHTML = loading;}
		if(xmlHttp.readyState == 1){document.getElementById("searchresult").innerHTML = loading;}
		if(xmlHttp.readyState == 2){document.getElementById("searchresult").innerHTML = loading;}
		if(xmlHttp.readyState == 3){document.getElementById("searchresult").innerHTML = loading;}
		if(xmlHttp.readyState == 4){
			document.getElementById("searchresult").innerHTML = xmlHttp.responseText;
		}
	};
	xmlHttp.open('POST',url,true); 
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(pmeters);
	}
</script>
*/ ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>
		<div style='padding:0px 0px 0px 0px;'>
      <form name="fsearch" method="post" action="" onSubmit="return false;">
        กรุณาเลือกประเภทที่จะค้นหา
        <select name="searchby" onChange="getform(this.value);" onFocus="getform(this.value)">
		<option value="5">ค้นหาโดย สถานที่</option>
		<option value="1">ค้นหาโดย วันที่ทำการแจ้ง</option>
		<option value="2">ค้นหาโดย ชื่อผู้แจ้ง</option>
		<option value="3">ค้นหาโดย เหตุเสียที่แจ้ง</option>
		<option value="4">ค้นหาโดย ช่วงวันที่แจ้งซ่อม</option>
		<option value="6">ค้นหาโดย  สถานะ</option>
		</select>
		<div id='formsearch' style='padding:10px 0px 10px 20px;'></div> 
	  </form>
	  </div>
    </td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><div id='searchresult' style='height:200px;padding:5px 10px 5px 10px;'></div></td>
  </tr>
</table>